/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */

bool isSametree(struct TreeNode* root, struct TreeNode* subRoot) {
    if (root == NULL && subRoot == NULL) {
        return true;
    }
    if (root == NULL || subRoot == NULL) {
        return false;
    }
    if (root->val != subRoot->val) {
        return false;
    }
    return isSametree(root->left, subRoot->left)
        && isSametree(root->right, subRoot->right);
}
bool isSubtree(struct TreeNode* root, struct TreeNode* subRoot) {
    if (root == NULL) {
        return false;
    }
    if (root->val == subRoot->val) {
        if (isSametree(root, subRoot)) {
            return true;
        }
    }
    return isSubtree(root->left, subRoot)
        || isSubtree(root->right, subRoot);
}